package com.yanqu.road.entity.activity.stelesoul;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.utils.property.Property;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@FieldTypeAnnotation(tableName = "t_u_stele_soul_user")
public class SteleSoulUserData extends DataObject {
    @FieldTypeAnnotation(desc = "活动ID", select = true, update = true)
    private int activityId;

    @FieldTypeAnnotation(desc = "玩家ID", select = true, update = true)
    private long userId;

    @FieldTypeAnnotation(desc = "轮次")
    private int round;

    @FieldTypeAnnotation(desc = "第N圈")
    private int circle;

    @FieldTypeAnnotation(desc = "地图数据")
    private Map<Integer, SteleSoulMapData> mapData;  // 第几圈，地图格子列表

    @FieldTypeAnnotation(desc = "参数1，起抽次数")
    private int paramOne;

    @FieldTypeAnnotation(desc = "参数2，保底次数")
    private int paramTwo;

    @FieldTypeAnnotation(desc = "上一次抽中位置")
    private String lastIndex;
    @FieldTypeAnnotation(desc = "本轮选的大奖")
    private Map<Integer, List<Property>> chosenReward = new ConcurrentHashMap<>();

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        if(this.activityId != activityId) {
            this.activityId = activityId;
            setUpdateOption();
        }
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if(this.userId != userId) {
            this.userId = userId;
            setUpdateOption();
        }
    }

    public int getRound() {
        return round;
    }

    public void setRound(int round) {
        if(this.round != round) {
            this.round = round;
            setUpdateOption();
        }
    }

    public int getCircle() {
        return circle;
    }

    public void setCircle(int circle) {
        if(this.circle != circle) {
            this.circle = circle;
            setUpdateOption();
        }
    }

    public Map<Integer, SteleSoulMapData> getMapData() {
        return mapData;
    }

    public void setMapData(Map<Integer, SteleSoulMapData> mapData) {
        this.mapData = mapData;
    }

    public int getParamOne() {
        return paramOne;
    }

    public void setParamOne(int paramOne) {
        if(this.paramOne != paramOne) {
            this.paramOne = paramOne;
            setUpdateOption();
        }
    }

    public int getParamTwo() {
        return paramTwo;
    }

    public void setParamTwo(int paramTwo) {
        if(this.paramTwo != paramTwo) {
            this.paramTwo = paramTwo;
            setUpdateOption();
        }
    }

    public String getLastIndex() {
        return lastIndex;
    }

    public void setLastIndex(String lastIndex) {
        if(this.lastIndex == null || !this.lastIndex.equals(lastIndex)) {
            this.lastIndex = lastIndex;
            setUpdateOption();
        }
    }

    public Map<Integer, List<Property>> getChosenReward() {
        return chosenReward;
    }

    public void setChosenReward(Map<Integer, List<Property>> chosenReward) {
        this.chosenReward = chosenReward;
    }

    public List<Property> getChosenRewardByRound(int round) {
        return chosenReward.getOrDefault(round, new ArrayList<>());
    }

    public void setChosenRewardByRound(int round, List<Property> reward) {
        chosenReward.put(round, reward);
        setUpdateOption();
    }
}
